package com.tianyiyan.hibernate.user;

import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.tianyiyan.tyenword.StaticData;

public class UserVerificationListener implements ServletContextListener
{
	private Timer timer = null;

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.print("Timer Cancel!");
		timer.cancel();
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		System.out.print("Timer Start!");
		/// Init StaticData
		StaticData.getInstance();
		timer = new Timer(true);
		timer.schedule(new ClearUserTask(StaticData.getInstance().getUserInvalidInterval()),
				0,
				StaticData.getInstance().getClearCycle());
	}
}
